using System;
using System.Collections.Generic;
using UnityEngine;

[Serializable]
public class tree_class
{
	public bool foldout;

	public bool interface_display;

	public int prototypeindex;

	public int placed;

	[NonSerialized]
	public tree_class placed_reference;

	public string swap_text;

	public bool swap_select;

	public bool copy_select;

	public Color color_tree;

	public precolor_range_class precolor_range;

	public bool scale_foldout;

	public bool link_start;

	public bool link_end;

	public float width_start;

	public float width_end;

	public float height_start;

	public float height_end;

	public float height;

	public float unlink;

	public bool random_position;

	public bool distance_foldout;

	public Vector3 min_distance;

	public distance_level_enum distance_level;

	public distance_mode_enum distance_mode;

	public rotation_mode_enum distance_rotation_mode;

	public bool distance_include_scale;

	public bool distance_include_scale_group;

	public bool data_foldout;

	public int mesh_length;

	public int mesh_triangles;

	public int mesh_combine;

	public Vector3 mesh_size;

	public List<distance_class> objects_placed;

	public prefilter_class prefilter;

	public bool raycast;

	public int layerMask;

	public float ray_length;

	public float cast_height;

	public float ray_radius;

	public Vector3 ray_direction;

	public raycast_mode_enum raycast_mode;

	public tree_class(terraincomposer_save script, bool new_filter)
	{
		interface_display = true;
		swap_text = "S";
		color_tree = new Color(1f, 1f, 1f, 1f);
		precolor_range = new precolor_range_class(1, one_color1: false);
		link_start = true;
		link_end = true;
		width_start = 1f;
		width_end = 2.5f;
		height_start = 1f;
		height_end = 2.5f;
		unlink = 0.25f;
		random_position = true;
		distance_include_scale = true;
		distance_include_scale_group = true;
		objects_placed = new List<distance_class>();
		prefilter = new prefilter_class();
		ray_length = 20f;
		cast_height = 20f;
		ray_radius = 1f;
		ray_direction = new Vector3(0f, -1f, 0f);
		if (new_filter)
		{
			script.add_filter(0, prefilter);
			script.filter[script.filter.Count - 1].type = condition_type_enum.Random;
			script.add_subfilter(0, script.filter[script.filter.Count - 1].presubfilter);
			script.subfilter[script.subfilter.Count - 1].type = condition_type_enum.Random;
			script.subfilter[script.subfilter.Count - 1].from_tree = true;
		}
		precolor_range.color_range[0].color_start = new Color(0.75f, 0.75f, 0.75f);
		precolor_range.color_range[0].color_end = new Color(1f, 1f, 1f);
	}

	public void count_mesh(GameObject object1)
	{
		if ((bool)object1)
		{
			MeshFilter meshFilter = (MeshFilter)object1.GetComponent(typeof(MeshFilter));
			Mesh mesh = null;
			Vector3[] array = null;
			int[] array2 = null;
			if ((bool)meshFilter)
			{
				mesh = meshFilter.sharedMesh;
				if ((bool)mesh)
				{
					array = mesh.vertices;
					mesh_size = mesh.bounds.size;
					array2 = mesh.triangles;
					if (array != null)
					{
						mesh_length = array.Length;
						mesh_combine = Mathf.FloorToInt(64000 / mesh_length);
						mesh_triangles = array2.Length;
					}
					else
					{
						UnityEngine.Debug.Log("vertices not found, cannot display data");
					}
				}
				else
				{
					UnityEngine.Debug.Log("mesh not found, cannot display data");
				}
			}
			else
			{
				UnityEngine.Debug.Log("meshfilter not found, cannot display data");
			}
		}
		else
		{
			mesh_combine = 0;
			mesh_size = new Vector3(0f, 0f, 0f);
			mesh_length = 0;
			mesh_triangles = 0;
		}
	}
}
